<template>
  <div>
    <Omanage 
    @parentSearch="parentSearch" 
    @parenttime="parenttimefun" 
	  @parenttrans="parentseach" 
	  @parentreset="initOrder" 
	  @parentselect="prabentselectfun" />
    <OrderList 
    @reseList="initOrder" 
    :typeObj="typeObj" 
    :myarr="myarr" 
    :typeCase="typeCase"/>
    <MyPage 
    :page="page" 
    :pageSize="pageSize" 
    :total="total" 
    @changepagesize="parentpagesize" 
    @changeVal="parentpage"/>
    <Dialog />
  </div>
</template>

<script>
import Omanage from './components/Omanage.vue'
import OrderList from './components/OrderList.vue'
import MyPage from './components/MyPage.vue'
import { getOrderApi,getCaseApi,gettimeApi } from '../../api/OrderApi'
export default {
  components:{
    Omanage,
    OrderList,
    MyPage,
    // Dialog
  },
  data() {
    return {
      typeObj:{
            2:'待支付',
            3:'已关闭',
            4:'待确认',
            5:'学习中',
            6:'已完成'
        },
        typeCase:{
          0:'幼儿英语入门',
          1:'幼儿数学入门',
          2:'幼儿法语入门',
          3:'幼儿美术入门',
        },
        myarr:[],
        keyword:'',
        page:1,//默认当前页 是第一页
        pageSize:10, //默认当前页显示20条
        total:0
    };
  },

  mounted() {
    this.initOrder();
  },

  methods: {

    parenttimefun(val){
     console.log(1111,val);
      var params={
          time1:this.time1,
          time2:this.time2
        }
        gettimeApi(params).then(res=>{
          console.log(res);
        })
   },

    //  当前页码的切换
   parentpage(val){
       this.page=val;
       this.initOrder()
   },

    //  每页有多少条
    parentpagesize(val){
      this.pageSize=val;
      this.page=1
      this.initOrder()
   },

    parentseach(val){
     this.keyword = val;
     this.initOrder()
   },

    parentSearch(val){
      this.keyword = val;
      this.initOrder();
    },

    prabentselectfun(val){
      console.log(val);
      var params={choice:val}
      getCaseApi(params).then(res=>{
            console.log(res);
          if(res.code==200){
              this.myarr=res.data
          }
      })
    },

    initOrder(){
      var params = { 
        key:this.keyword, 
        page:this.page,
        pagesize:this.pageSize };
      this.keyword=''
      getOrderApi(params).then(res=>{
        console.log(res);
        if(res.code==200){
          this.myarr=res.data;
          this.total=res.total;
        }
      })
    },
  },
};
</script>

<style lang="less" scoped>

</style>

</style>